package com.example.navigation_inclusive.screen

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.example.navigation_inclusive.graph.Router

@Composable
fun LoginScreen(navController: NavController) {
    Column(
        modifier = Modifier.fillMaxSize(),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Text(text = "Login Screen")
        Spacer(modifier = Modifier.height(20.dp))
        Button(onClick = {
            /**
             * popUpTo --> // 在跳转到 Home 之前 ，清空回退栈中home之上到栈顶的所有页面（不包含home）
             * popUpTo { inclusive = true }--> // 在跳转到 Home 之前 ，清空回退栈中home之上到栈顶的所有页面（包含home）
             */
            navController.navigate(Router.home) {
//                popUpTo(Router.login) { inclusive = false }
            }
        }) {
            Text(text = "Login")
        }
    }
}